package com.eastmoney.emis.edda.infrastructure.hsbc.dto;

import com.eastmoney.emis.edda.infrastructure.report.Report;
import com.eastmoney.emis.edda.infrastructure.util.ZipUtils;
import org.springframework.util.StringUtils;

import java.io.IOException;
import java.util.Base64;
import java.util.Collections;
import java.util.List;

/**
 * @description: Description
 * @projectName: EDDA-HSBC
 * @package: com.eastmoney.emis.edda.infrastructure.dto
 * @author: 汪程程
 * @date: 2022/9/27 1:54 PM
 * @version: 1.0
 */
public class ReportsResp extends HsbcEddaBaseResp{

    public String ReportContent;

    public List<Report> decode() throws IOException {
        if(!StringUtils.hasText(ReportContent)) {
            return Collections.emptyList();
        }
        return ZipUtils.unzip(getZipBytes());
    }

    public byte[] getZipBytes() {
        if(!StringUtils.hasText(ReportContent)) {
            return new byte[0];
        }
        return Base64.getDecoder().decode(ReportContent);
    }

    @Override
    public String toString() {
        return "ReportsResp{" +
                "ReportContent='" + ReportContent + '\'' +
                ", ProcessResult=" + ProcessResult +
                ", Id='" + Id + '\'' +
                ", Code='" + Code + '\'' +
                ", Message='" + Message + '\'' +
                ", Errors=" + Errors +
                '}';
    }
}
